/*
 * TODO: Description
 *
 * Copyright (C) 2010 Johan Waldeback
 *  
 * This file is part of the OpenFMS project (http://www.openfms-project.org)
 * 
 * OpenFMS is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __INPUTDEVICE_H__
#define __INPUTDEVICE_H__

#include <tchar.h>
#include <stdint.h>
#ifdef _WIN32 
#include <windows.h>
#endif // _WIN32

namespace OpenFms
{

typedef uint64_t (*InputDevice_create_fn)();
typedef uint32_t (*InputDevice_destroy_fn)(uint64_t);
typedef uint32_t (*InputDevice_get_number_of_channels_fn)(uint64_t);
typedef uint32_t (*InputDevice_capture_fn)(uint64_t , float *, uint32_t, uint32_t);

class InputDevice
{
private:
	InputDevice_create_fn m_create_fn;      /**< Function pointer to the \c create function in the dynamic library */
	InputDevice_destroy_fn m_destroy_fn;    /**< Function pointer to the \c destroy function in the dynamic libaray */
	InputDevice_get_number_of_channels_fn m_get_number_of_channels_fn; /**< Function pointer to the \c get_number_of_channels function in the dynamic libaray */
	InputDevice_capture_fn m_capture_fn;    /**< Function pointer to the \c capture function in the dynamic libaray */
private:
	uint64_t m_handle;  /**< Handle returned by call to the \c create funtion in the dynamic library */

#ifdef _WIN32
	HMODULE m_hDll;  /**< Handle to the dynamic library (Windows) */
#endif // _WIN32

public:
	InputDevice();
	~InputDevice();
	bool loadLibrary( const TCHAR *filename );
	void unloadLibrary();
	bool createDevice();
	bool destroyDevice();

	bool isLoaded();
	int getNumberOfChannels();
	bool capture( float *p, size_t start, size_t length);

};
}// namespace OpenFms

#endif // __INPUTDEVICE_H__

